//Blue Tails' moveset

addHook("PlayerThink", function(player)
	if player.mo and player.mo.valid
		if player.tailsflyrun == nil
			player.tailsflyrun = 0
		end
		if player.tailsstraightflyrun == nil
			player.tailsstraightflyrun = false
		end
		if player.tailsflyrun > 0
			player.tailsflyrun = $-1
			player.mo.flags = $|MF_NOGRAVITY
			if (leveltime % 10) == 1
				S_StartSound(player.mo, sfx_putput)
			end
		end
		if player.tailstintblue == true
		and player.isblue == true
			if player.mo.state == S_PLAY_RUN
			and player.speed >= player.runspeed
			and not (P_IsObjectOnGround(player.mo))
			and player.tailsflyrun <= 0
			and player.dasupafomr == false
			and not (player.mo.flags & MF_NOGRAVITY)
				player.tailsflyrun = 3*TICRATE
			end
			if player.mo.flags & MF_NOGRAVITY
			and player.powers[pw_super] == false
				if player.mo.state != S_PLAY_RUN
				or player.speed < player.runspeed
				or P_IsObjectOnGround(player.mo)
				or player.tailsflyrun <= 0
					player.mo.flags = $ & ~MF_NOGRAVITY
					P_DoJump(player, true)
					player.pflags = $ & ~PF_JUMPED
					player.mo.state = S_PLAY_SPRING
					player.tailsflyrun = 0
				end
			end
		end
		if player.tailstintblue == true
		and player.isblue == true
		and player.mo.state == S_PLAY_FLY or player.mo.state == S_PLAY_FLY_TIRED
			if player.cmd.buttons & BT_USE
				player.pflags = $|PF_JUMPED
				player.mo.state = S_PLAY_ROLL
				S_StartSound(player.mo, sfx_spndsh, player)
				player.powers[pw_tailsfly] = 0
			end
		end
	end
end)